/**
*      author: Y_Yao
*      created: 2025-02-09 17:51:00
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 5e5 + 7;
int a[N],b[N];
int ans;
int n;

void msort(int l,int r)
{
    if(l == r)
    {
        return;
    }

    int mid = (l + r) >> 1,i = l,j = mid + 1;
    int k = l;
    msort(l,mid);
    msort(mid + 1,r);

    while(i <= mid && j <= r)
    {
        if(a[i] <= a[j])
        {
            b[k++] = a[i++];
        }
        else
        {
            b[k++] = a[j++];
            ans += mid - i + 1;
        }
    }

    while(i <= mid)
    {
        b[k++] = a[i++];
    }
    while(j <= r)
    {
        b[k++] = a[j++];
    }

    for(int i = l;i <= r;i++)
    {
        a[i] = b[i];
    }
}

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
    }

    msort(1,n);
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}